{{--/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/3/2 8:33
 * Desc:
 */--}}
@extends("layout.admin")

@section("title")
    系统设置
@endsection

@section("content")
    <style>
        .input-width {
            width: 32%;
        }
    </style>
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li><a href="{{route('admin.set.index')}}">基础设置</a></li>
            <li><a href="{{route('admin.set.index.attach.1')}}">顶部导航</a></li>
            <li><a href="{{route('admin.set.index.attach.2')}}">用户设置</a></li>
            <li><a href="{{route('admin.set.index.attach.3')}}">微信设置</a></li>
            <li><a href="{{route('admin.set.index.attach.4')}}">企业微信设置(待完成)</a></li>
            <li class="layui-this"><a href="{{route('admin.set.index.attach.5')}}">钉钉设置</a></li>
            <li>云存储(暂缓)</li>
        </ul>
        <div class="layui-tab-content" style="height: auto;">
            {{--基础设置--}}
            <div class="layui-tab-item layui-show">
                <form class="layui-form" action="" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">钉钉登陆</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_open" value="YES" title="YES"
                                   @if($error==0) @if($set["value"]['is_open']==1) checked @endif @endif>
                            <input type="radio" name="is_open" value="NO" title="NO"
                                   @if($error==0) @if($set["value"]['is_open']==0) checked @endif @endif>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-form-mid layui-word-aux">
                            钉钉账号仅作为第三方登录方式绑定已有平台账号。<br/>
                            若需启用钉钉部门和员工信息同步，请在 【账号同步对接】中开启"钉钉企业内H5微应用"。<br/>
                            请用企业钉钉管理员账号登录 钉钉开发者平台,在“应用开发-移动接入应用-登录”中通过“创建扫码登录应用授权”以获取APP ID和App Secret。
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">App ID</label>
                        <div class="layui-input-block">
                            <input type="text" id="appID" name="appID" lay-verify="required" autocomplete="off"
                                   placeholder="请输入AppID" class="layui-input input-width"
                                   @if($error==0) value="{{$set["value"]["appID"]}}" @elseif($error>0) value="" @endif>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">App Secret</label>
                        <div class="layui-input-block">
                            <input type="text" id="appSecret" name="appSecret" lay-verify="required" autocomplete="off"
                                   placeholder="请输入AppSecret" class="layui-input input-width"
                                   @if($error==0) value="{{$set["value"]["appSecret"]}}"
                                   @elseif($error>0) value="" @endif>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" id="sub" class="layui-btn" data-name="dingtalk" lay-submit="">提交
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection

@section("script")
    <script>
        layui.use(['element', 'form', 'upload'], function () {
            var $ = layui.jquery
                , element = layui.element //Tab的切换功能，切换事件监听等，需要依赖element模块
                , form = layui.form
                , upload = layui.upload;

            $("#sub").click(function (data) {
                let name = data.currentTarget.dataset.name;
                let value = {"name": $("#name").val(), "appID": $("#appID").val(), "appSecret": $("#appSecret").val(),"is_open":$("#is_open").val()=="YES"?1:0};
                admin.set("{{route('admin.set.create')}}", "{{csrf_token()}}", name, value);
            });
        });
    </script>
@endsection

